{include file='public/_meta'}
<title>添加管理员</title>
</head>
<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-admin-add" method="post" action="{:url('admin/user/editdo')}">
    <input type="hidden" id="id" name="id" value="{$info.id}" />
    <div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="{$info.uname}" placeholder="" id="uname" name="uname">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>初始密码：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="password" class="input-text" autocomplete="off" value="" placeholder="密码" id="upass" name="upass">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="password" class="input-text" autocomplete="off"  placeholder="确认新密码" id="upass2" name="upass2">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>姓名：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="{$info.name}" placeholder="" id="name" name="name">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性别：</label>
		<div class="formControls col-xs-8 col-sm-9 skin-minimal">
			<div class="radio-box">
				<input name="sex" type="radio" value="男" id="sex-1" {if $info.sex=='男'}checked{/if} >
				<label for="sex-1">男</label>
			</div>
			<div class="radio-box">
				<input type="radio" id="sex-2" value="女" name="sex" {if $info.sex=='女'}checked{/if} >
				<label for="sex-2">女</label>
			</div>
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>手机：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="{$info.phone}" placeholder="" id="phone" name="phone">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>邮箱：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="{$info.email}" placeholder="@" name="email" id="email">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">角色：</label>
		<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
			<select class="select" name="pid" size="1">
                {foreach $plist as $k=>$v}
                <option {if $v.id==$roles.0.id}selected{/if} value="{$v.id}">{$v.name}</option>
                {if $v.childrens}
                    {foreach $v.childrens as $ck=>$cv}
                    <option {if $cv.id==$roles.0.id}selected{/if} value="{$cv.id}">|-- {$cv.name}</option>
                    {/foreach}
                {/if}
                {/foreach}
			</select>
			</span> </div>
	</div>
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		</div>
	</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去--> 
{include file='public/_footer'}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="__PUBLIC__lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="__PUBLIC__lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-admin-add").validate({
		rules:{
			uname:{
				required:true,
				minlength:4,
				maxlength:16
			},
			upass:{
			},
			upass2:{
				equalTo: "#upass"
			},
			sex:{
				required:true,
			},
			phone:{
				isPhone:true,
			},
			email:{
				email:true,
			},
			pid:{
				required:true,
			},
		},
		//onkeyup:false,
		//focusCleanup:true,
		//success:"valid",
		submitHandler:function(form){
            /**
            * 成功之后的回调函数
            * @type {{success: options.success}}
            */
            var options = {
                success: function (data) {
                    var dataobj =  JSON.parse(data);
                    if(parseInt(dataobj.statusCode)==200){
                        layer.msg(dataobj.message,{icon:1,time:1000});
                        setInterval("closeWindow()",1000);
                        return true;
                    }else{
                        layer.msg(dataobj.message,{icon:5,time:1000});
                        return false;
                    }
                }
            };
            $(form).ajaxSubmit(options);
		}
	});
});
function closeWindow(){
    var index = parent.layer.getFrameIndex(window.name);
    window.parent.location.reload();
}
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>